$(function(){
	var sb = new Z.ScrollBox({
		'target' : $('#footer-bar div.description-container div.description'),
		'height' : 300,
		'verticalBlockHeight' : 90,
		'barWidth' : 10
	});
    
	$('#footer-bar div.description-container').hide();
    
	$('#footer-bar li.description a').click(function(){
		$('#footer-bar p').toggle();
		$(this).parent().toggleClass('active');
	});
    
	$('#footer-bar li.description a').toggle(function(){
		$('#footer-bar div.description-container').show();
		$(this).parent().addClass('open');
		$(this).html('CLOSE');
	},function(){
		$('#footer-bar div.description-container').hide();
		$(this).parent().removeClass('open');
		$(this).html('MORE');
	});
    
	var length = $('.buttons a').length;
	var index = 0;
	$('.image-container ul').width(length * $(document).width());
	$('.image-container ul li').width($(document).width());
	$('a#previous').hide();
	$('a#previous').click(function(){
		index--;
		moving(index);
	});
	$('a#next').click(function(){
		index++;
		moving(index);
	});
	$('.buttons a').each(function(i, item){
		$(this).click(function(){
			index = i;
			moving(index);
		});
	});
	
	function moving(index){
		if(index == (length - 1)){
			$('a#next').hide();
		}else if(index == 0){
			$('a#previous').hide();
		}else{
			$('a#previous').show();
			$('a#next').show();
		}
		$('.buttons a.active').removeClass('active');
		$('.buttons a').eq(index).addClass('active');
		$('div.image-container ul').css({'left':(-index * $(document).width())+'px'});
		//$('div.image-container ul').animate({'left':(-index * $(document).width())+'px'}, 300);
	}
	
});